package view;

import java.util.Observable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import controller.Presenter;
import view.Board;


public class Game2048View extends Observable implements View,Runnable {
	
	Board bord;
	Display display;
	Shell shell;
	static int n = 4;
	static int m = 4;
	static int[][] Game2048Array = new int[n][m]; 
	
	private void initComponents() {
		display = new Display();
		shell = new Shell(display);
		shell.setLayout(new org.eclipse.swt.layout.GridLayout(2, false));
		shell.setSize(500, 500);
		shell.setText("My 2048 Game");
		
		Button button1 = new Button(shell, SWT.PUSH);
		button1.setText("Button 1");
		button1.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
		
		Board board = new Board(shell, SWT.BORDER);
		board.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
		
		Button button2 = new Button(shell, SWT.PUSH);
		button2.setText("Button 2");
		button2.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
		
		shell.open();
	
	}

	public void displayData(int[][] Game2048Array ) {
	
		display.syncExec(new Runnable() {
			
			@Override
			public void run() {
				
				
			}
		});	
	}

	public int getUserCommand() {
		// TODO Auto-generated method stub
		return 0;
	}

	public void run() {
		initComponents();
		while(!shell.isDisposed()) {
			if(!display.readAndDispatch()) {
				display.sleep();
			}
		}
			
		display.dispose();
	}

	@Override
	public void addObserver(Presenter p) {
		// TODO Auto-generated method stub
		
	}

}
